package com.java.base.exercise.designmode.proxy.cglibproxy;

import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

/**
 * @Author RenPu
 * @Date 2022/6/20 16:53
 * @Version 1.0
 * @Description: 实现Cglib具体处理业务方法的逻辑类
 **/
public class CglibMethodInterceptor implements MethodInterceptor {
    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        //调用方法之前执行
        System.out.println("Cglib 动态代理调用之后执行.......:"+method.getName());
        Object aSuper = methodProxy.invokeSuper(o, objects);
        System.out.println("Cglib 动态代理调用之后执行.......:"+method.getName());
        return aSuper;
    }
}
